package com.ict.txmsv2.services;

import com.ict.txmsv2.mapper.MenuMapper;
import com.ict.txmsv2.model.Menu;
import com.ict.txmsv2.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yoleen
 * @date 2020/2/26 10:04
 */

@Service
public class MenuService {
    @Autowired
    MenuMapper menuMapper;
    public List<Menu> getMenuByUserid() {
        return menuMapper.getMenuByUserid(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    public List<Menu> getAllMenusWithRoles(){
        return menuMapper.getAllMenusWithRoles();
    }

    public List<Menu> getAllMenus() {
        return menuMapper.getAllMenus();
    }
}
